//
//  ZNewMemberGroupCell.m
//  WeClubs
//
//  Created by Zed Link on 20/4/2017.
//  Copyright © 2017 Zed. All rights reserved.
//

#import "ZNewMemberGroupCell.h"
#import <Masonry.h>
#import "ZNewNotifyCollectionCell.h"
#import "ZStudentModel.h"
#import <SDWebImage/UIImageView+WebCache.h>
static NSString *MemberGroupReuseCell = @"ZMemberGroupReuseCell";

@interface ZNewMemberGroupCell ()


@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@property (weak, nonatomic) IBOutlet UIView *separatorView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *separatorViewHeight;

@end

@implementation ZNewMemberGroupCell

- (void)setDataArr:(NSArray *)dataArr{

    _dataArr = dataArr;
    [self.collectionView reloadData];

}

- (void)zSetupCell
{
    [super zSetupCell];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    [self.contentView setBackgroundColor:NAVBAR_BG_COLOR];
    
    
    UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout;
    layout.itemSize = CGSizeMake(45, 76);
    layout.minimumLineSpacing = 8;
    
    [self.collectionView setBackgroundColor:[UIColor clearColor]];
    [self.collectionView registerClass:[ZNewNotifyCollectionCell class] forCellWithReuseIdentifier:MemberGroupReuseCell];
    [self.separatorView setBackgroundColor:GENERAL_VIEW_BG_COLOR];
}

- (void)hideSeparatorView
{
    self.separatorViewHeight.constant = 0;
}

#pragma mark - UICollectionViewDataSource & UICollectionViewDelegate

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    return self.dataArr.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{

    ZNewNotifyCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:MemberGroupReuseCell forIndexPath:indexPath];
    cell.model = self.dataArr[indexPath.row];
    return cell;

}

@end



@implementation ZNewMemberGroupItem

- (void)zSetupCell
{
    // ========== 添加按钮 ==========
    UIColor *color = FONT_MAIN_COLOR;
    ZVerticalButton *button = [ZVerticalButton zVerticalButtonWithTitle:@"" fontSize:11 color:color image:nil];
    button.space = 8;
    [button.imageView zCornerDeal:18];
    [button setBackgroundColor:[UIColor clearColor]];
    
    self.button = button;
    [self.contentView addSubview:button];
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsMake(0, 0, 0, 0));
    }];
}

@end
